﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WISD.CarFriend.Model;
using WISD.Common;
using WISD.CarFriend.BLL;
using WISD.CarFriend.BLL.Web;


namespace WISD.CarFriend.Web.Admin.Module.InformationManage
{
    public partial class Add : Utility.BasicPage
    {
        /// <summary>
        /// Page_Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    // 验证权限
                    base.CheckPermission("InformationManage_Add");

                    ddl_type.DataSource = TypeManageModule.GetAllType();
                    ddl_type.DataTextField = "TypeName";
                    ddl_type.DataValueField = "TypeID";
                    ddl_type.DataBind();
                }
            }
            catch (Exception exception)
            {
                base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>" + exception.Message.ToString(), "back", "Error");
            }
        }


        /// <summary>
        /// 新增资讯
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                T_CF_Web_Information info = new T_CF_Web_Information();
                info.Title = txtTitle.Text.Trim();
                info.TypeID =int.Parse( ddl_type.SelectedValue);
                info.IsTop = cb_Istop.Checked;
                info.InfoContent = FCKeditor.Value;
                info.CreatorID = Session["UserID"].ToInt();
                InformationManageModule.InsertNewInfo(info);
                ShowMessageBox("新增资讯成功！", "Add.aspx", "Success");
            }
            catch (Exception exception)
            {
                base.ShowMessageBox(350, 230, "错误提示", "<b>出现错误啦！</b>" + exception.Message.ToString(), "back", "Error");
            }
        }

    }
}